//
//  danmuItem.m
//  弹幕
//
//  Created by 宋旭东 on 15/8/7.
//  Copyright (c) 2015年 灵犀一点. All rights reserved.
//

#import "danmuItem.h"

@implementation danmuItem
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor blackColor];
        [self createSubviews:frame];
    }
    return self;
}
- (void)createSubviews:(CGRect)frame
{
    self.avatar = [[UIImageView alloc] initWithFrame:CGRectZero];
//    [_avatar setContentScaleFactor:[[UIScreen mainScreen] scale]];
//    _avatar.layer.cornerRadius = 10;
//    _avatar.layer.borderColor = [[UIColor whiteColor] CGColor];
//    _avatar.layer.borderWidth = 2;
//    _avatar.layer.masksToBounds = YES;
//    _avatar.contentMode =  UIViewContentModeScaleAspectFill;
//    _avatar.clipsToBounds  = YES;
//    _avatar.backgroundColor = [UIColor brownColor];
    self.content = [[UILabel alloc] initWithFrame:CGRectZero];
    _content.font = [UIFont systemFontOfSize:17];
    _content.textAlignment = NSTextAlignmentCenter;
    _content.textColor = [UIColor whiteColor];
    [self addSubview:_avatar];
    [self addSubview:_content];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _avatar.frame = CGRectMake(0, 0, self.frame.size.height, self.frame.size.height);
    _content.frame = CGRectMake(_avatar.frame.size.width, 0, self.frame.size.width - _avatar.frame.size.width, self.frame.size.height);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
